package com.entmanage.base.memo.controller;


import com.entmanage.base.memo.domain.MemoReminder;
import com.entmanage.base.memo.service.IMemoReminderService;
import com.entmanage.base.memo.service.impl.MemoReminderServiceImpl;
import io.swagger.annotations.Api;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.entmanage.common.annotation.Log;
import com.entmanage.common.core.controller.BaseController;
import com.entmanage.common.core.domain.AjaxResult;
import com.entmanage.common.enums.BusinessType;
import com.entmanage.common.utils.poi.ExcelUtil;
import com.entmanage.common.core.page.TableDataInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 备忘录提醒Controller
 *
 * @author lsq
 * @date 2025-09-04
 */
@Api(tags = {"memo-MemoReminder模块"}, description = "备忘录提醒")
@RestController
@RequestMapping("/memo/reminder")
public class MemoReminderController extends BaseController
{
    private static final Logger log = LoggerFactory.getLogger(MemoReminderServiceImpl.class);

    @Autowired
    private IMemoReminderService memoReminderService;

    /**
     * 查询备忘录提醒列表
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemoReminder memoReminder)
    {
        startPage();
        List<MemoReminder> list = memoReminderService.selectMemoReminderList(memoReminder);
        return getDataTable(list);
    }

    /**
     * 导出备忘录提醒列表
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:export')")
    @Log(title = "备忘录提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemoReminder memoReminder)
    {
        List<MemoReminder> list = memoReminderService.selectMemoReminderList(memoReminder);
        ExcelUtil<MemoReminder> util = new ExcelUtil<MemoReminder>(MemoReminder.class);
        util.exportExcel(response, list, "备忘录提醒数据");
    }

    /**
     * 获取备忘录提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memoReminderService.selectMemoReminderById(id));
    }

    /**
     * 新增备忘录提醒
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:add')")
    @Log(title = "备忘录提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemoReminder memoReminder)
    {
        return toAjax(memoReminderService.insertMemoReminder(memoReminder));
    }

    /**
     * 修改备忘录提醒
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:edit')")
    @Log(title = "备忘录提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemoReminder memoReminder)
    {
        return toAjax(memoReminderService.updateMemoReminder(memoReminder));
    }

    /**
     * 删除备忘录提醒
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:remove')")
    @Log(title = "备忘录提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memoReminderService.deleteMemoReminderByIds(ids));
    }

    /**
     * 发送备忘录提醒邮件
     */
    @PreAuthorize("@ss.hasPermi('memo:reminder:send')")
    @Log(title = "备忘录提醒", businessType = BusinessType.SEND)
    @PostMapping("/sendEmail")
    public AjaxResult sendEmail(@RequestParam Long id) {
        if (id == null) {
            return AjaxResult.error("缺少参数：id");
        }
        memoReminderService.sendReminderEmail(id);
        return AjaxResult.success("邮件发送任务已提交，将在后台处理");
    }
}
